package com.sgam.mf.domain.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.springframework.format.annotation.DateTimeFormat;

import com.sgam.utils.CustomDateDeserializer;
import com.sgam.utils.CustomDateSerializer;

@Entity
@Table(name = "REG_PERSONS")
public class RegPersons {


	@Id
	@Column(name = "id")
	@GeneratedValue
	private Integer id;
	
	@Column(name = "idnp")
    private String idnp;
	 
	@Column(name = "last_name")
    private String lastName;
	
	@Column(name = "first_name")
    private String firstName;
	
	@Column(name = "patronymic")
    private String patronymic;
	
	@Column(name = "sex")
    private String sex;
 
	@JsonSerialize(using = CustomDateSerializer.class)
	@JsonDeserialize(using = CustomDateDeserializer.class)
	@DateTimeFormat(pattern="dd.MM.yyyy")
	@Column(name = "birth_date")
    private Date birthDate;	

	@Column(name = "address")
    private String address;	

	@Column(name = "ocupatia")
    private String ocupatia;		
	
	@Column(name = "emal")
    private String emal;
	
	@Column(name = "phone_home")
    private String phoneHome;
	
	@Column(name = "phone_mob")
    private String phoneMob;
	
	@Column(name = "phone_serv")
    private String phoneServ;
	
	@Column(name = "skype")
    private String skype;
	
	@Column(name = "notes")
    private String notes;
	
	@Column(name = "updated_by_fk")
    private Integer updatedByFk;	
	
	@JsonSerialize(using = CustomDateSerializer.class)
	@JsonDeserialize(using = CustomDateDeserializer.class)
	@DateTimeFormat(pattern="dd.MM.yyyy")
	@Column(name = "updated_date")
    private Date updatedDate;	
	
//	@Column(name = "ref_company_fk")
//    private Integer refCompanyFk;	
	
	@ManyToOne
	@JoinColumn(name = "reg_company_fk", nullable = true)
	private RegCompanies regCompanies;
	
	@JsonSerialize(using = CustomDateSerializer.class)
	@JsonDeserialize(using = CustomDateDeserializer.class)
	@DateTimeFormat(pattern="dd.MM.yyyy")
	@Column(name = "asig_rca_date")
    private Date asigRcaDate;	
	
	@JsonSerialize(using = CustomDateSerializer.class)
	@JsonDeserialize(using = CustomDateDeserializer.class)
	@DateTimeFormat(pattern="dd.MM.yyyy")
	@Column(name = "asig_casco_date")
    private Date asigCascoDate;	
	
	@OneToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER, orphanRemoval=true)
	@Fetch(value = FetchMode.SUBSELECT)
	@JoinColumn(name="parent_id_fk")
//	@OrderBy("refPropertyType.id")
	private List<RegPersonsAss> regPersonsAss = new ArrayList<RegPersonsAss>();
	
	@OneToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER, orphanRemoval=true)
	@Fetch(value = FetchMode.SUBSELECT)
	@JoinColumn(name="reg_persons_id_fk")
	@OrderBy("refDomains.id")
	private List<ClientFiles> clientFiles = new ArrayList<ClientFiles>();
	

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getIdnp() {
		return idnp;
	}

	public void setIdnp(String idnp) {
		this.idnp = idnp;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getPatronymic() {
		return patronymic;
	}

	public void setPatronymic(String patronymic) {
		this.patronymic = patronymic;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public Date getBirthDate() {
		return birthDate;
	}

	public void setBirthDate(Date birthDate) {
		this.birthDate = birthDate;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getOcupatia() {
		return ocupatia;
	}

	public void setOcupatia(String ocupatia) {
		this.ocupatia = ocupatia;
	}

	public String getEmal() {
		return emal;
	}

	public void setEmal(String emal) {
		this.emal = emal;
	}

	public String getPhoneHome() {
		return phoneHome;
	}

	public void setPhoneHome(String phoneHome) {
		this.phoneHome = phoneHome;
	}

	public String getPhoneMob() {
		return phoneMob;
	}

	public void setPhoneMob(String phoneMob) {
		this.phoneMob = phoneMob;
	}

	public String getPhoneServ() {
		return phoneServ;
	}

	public void setPhoneServ(String phoneServ) {
		this.phoneServ = phoneServ;
	}

	public String getSkype() {
		return skype;
	}

	public void setSkype(String skype) {
		this.skype = skype;
	}

	public String getNotes() {
		return notes;
	}

	public void setNotes(String notes) {
		this.notes = notes;
	}

	public Integer getUpdatedByFk() {
		return updatedByFk;
	}

	public void setUpdatedByFk(Integer updatedByFk) {
		this.updatedByFk = updatedByFk;
	}

	public Date getUpdatedDate() {
		return updatedDate;
	}

	public void setUpdatedDate(Date updatedDate) {
		this.updatedDate = updatedDate;
	}

	public RegCompanies getRegCompanies() {
		return regCompanies;
	}

	public void setRegCompanies(RegCompanies regCompanies) {
		this.regCompanies = regCompanies;
	}

	public Date getAsigRcaDate() {
		return asigRcaDate;
	}

	public void setAsigRcaDate(Date asigRcaDate) {
		this.asigRcaDate = asigRcaDate;
	}

	public Date getAsigCascoDate() {
		return asigCascoDate;
	}

	public void setAsigCascoDate(Date asigCascoDate) {
		this.asigCascoDate = asigCascoDate;
	}

	public List<RegPersonsAss> getRegPersonsAss() {
		return regPersonsAss;
	}

	public void setRegPersonsAss(List<RegPersonsAss> regPersonsAss) {
		this.regPersonsAss = regPersonsAss;
	}

	public List<ClientFiles> getClientFiles() {
		return clientFiles;
	}

	public void setClientFiles(List<ClientFiles> clientFiles) {
		this.clientFiles = clientFiles;
	}
	
	
}


 

